package com.neu.af.controller;

import com.neu.af.common.base.BaseController;
import com.neu.af.common.base.BaseModelJson;
import com.neu.af.dataFilter.entity.pojo.*;
import com.neu.af.dataFilter.service.DataStatsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/dataOp")
public class DataStatsController extends BaseController {
    @Autowired
    DataStatsService dataStatsService;

    /**
     * 获取数据统计界面上端整体信息
     * @return
     */
    @RequestMapping(value = "/getAllCount",method = RequestMethod.GET)
    public BaseModelJson<Map> getAllCount() {
        BaseModelJson<Map> result = new BaseModelJson<>();
        Map<String, Object> map = new HashMap<>();
        AllCount allCount = dataStatsService.getAllCount();
        map.put("allCount", allCount);
        result.code = 200;
        result.message = "success";
        result.data = map;
        return result;
    }

    @RequestMapping(value = "/getOneWeekCount",method = RequestMethod.GET)
    public BaseModelJson<Map> getOneWeekCount() {
        BaseModelJson<Map> result = new BaseModelJson<>();
        Map<String, Object> map = new HashMap<>();
        List<OneWeekCount> oneWeekCount = dataStatsService.getOneWeekCount();
        map.put("allCount", oneWeekCount);
        result.code = 200;
        result.message = "success";
        result.data = map;
        return result;
    }

    @RequestMapping(value = "/getAlarmCountByJizu",method = RequestMethod.GET)
    public BaseModelJson<Map> getAlarmCountByJizu() {
        BaseModelJson<Map> result = new BaseModelJson<>();
        Map<String, Object> map = new HashMap<>();
        List<JizuAlarmCount> jizuAlarmCounts = dataStatsService.getAlarmCountByJizu();
        map.put("allCount", jizuAlarmCounts);
        result.code = 200;
        result.message = "success";
        result.data = map;
        return result;
    }
    @RequestMapping(value = "/getCompareAlarmCount",method = RequestMethod.GET)
    public BaseModelJson<Map> getCompareAlarmCount() {
        BaseModelJson<Map> result = new BaseModelJson<>();
        Map<String, Object> map = new HashMap<>();
        CompareAlarmCount compareAlarmCount = dataStatsService.getCompareAlarmCount();
        map.put("allCount", compareAlarmCount);
        result.code = 200;
        result.message = "success";
        result.data = map;
        return result;
    }
    @RequestMapping(value = "/getRankAlarmCount",method = RequestMethod.GET)
    public BaseModelJson<Map> getRankAlarmCount() {
        BaseModelJson<Map> result = new BaseModelJson<>();
        Map<String, Object> map = new HashMap<>();
        List<RankAlarmCount> rankAlarmCount = dataStatsService.getRankAlarmCount();
        map.put("cnt",rankAlarmCount.size());
        map.put("rankData", rankAlarmCount);
        result.code = 200;
        result.message = "success";
        result.data = map;
        return result;
    }
}